<template>
	<view class="user-page">
		<view class="head">
			<view class="title">
				<text>我的</text>
			</view>

			<view class="user">
				<!-- <image :src="vuex_user.avatar" mode="aspectFill"></image> -->
			
				<view class="center">
					<view class="t1">
						<text>{{vuex_user.name}}</text>
					</view>
					<view class="t2">
						<text>{{vuex_user.mobile}}</text>
					</view>
					<view class="t2">
						<text>工号：{{vuex_user.assessor_no}}</text>
					</view>
				</view>
			
				<view class="right">
					<text class="t1">{{complete_num}}</text>
					<text class="t2">已完成考评数</text>
				</view>
			</view>
		</view>

		<!-- 功能列表 -->
		<view class="list">
			<view class="item" @click="gotopage('/pagesA/record/record')">
				<image class="img1" src="../../static/user-time.png" mode="aspectFit"></image>
				<text>我的考评记录</text>
				<image class="img2" src="../../static/icon-right.png" mode="aspectFit"></image>
			</view>
			<view class="item" @click="gotopage('/pagesA/handbook/handbook')">
				<image class="img3" src="../../static/user-book.png" mode="aspectFit"></image>
				<text>考评手册</text>
				<image class="img2" src="../../static/icon-right.png" mode="aspectFit"></image>
			</view>
			<view class="item" @click="gotopage('/pagesA/change-password/change-password')">
				<image class="img4" src="../../static/user-lock.png" mode="aspectFit"></image>
				<text>修改密码</text>
				<image class="img2" src="../../static/icon-right.png" mode="aspectFit"></image>
			</view>
			<view class="item" @click="logout">
				<image class="img4" src="../../static/user-lock.png" mode="aspectFit"></image>
				<text>退出</text>
				<image class="img2" src="../../static/icon-right.png" mode="aspectFit"></image>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				complete_num:0
			}
		},
		
		mounted() {
			this.getdata(true);
		},
		methods: {
			getdata(refresh){
				this.$u.post('/getSuccessNumber').then(res => {
					if (refresh) {
						this.complete_num = res.complete_num
					}
				});
			},
			gotopage(url) {
				uni.navigateTo({ url })
			},
			
			logout() {
				this.$u.vuex('vuex_user', {})
				this.$u.vuex('vuex_token', '')
				uni.clearStorageSync()
				uni.navigateTo({
					url: '../login/login'
				})
			}
		},
		onPullDownRefresh() {
			if (this.tabIdx == 0) {
				this.$refs.user.getdata(true)
			}
			setTimeout(() => {
				uni.stopPullDownRefresh()
			}, 1000)
		},
	}
</script>

<style lang="scss" scoped>
	.user-page {
		width: 750rpx;

		.head {
			width: 100%;
			height: 378rpx;
			padding-top: 106rpx;
			border-radius: 0 0 100rpx 0;
			background-image: linear-gradient(to right, #6ABDDC, #239DC9);

			.title {
				font-size: 36rpx;
				font-family: PingFang SC;
				font-weight: bold;
				line-height: 50rpx;
				color: #FFFFFF;
				text-align: center;
			}

			.user {
				margin-top: 46rpx;
				display: flex;
				align-items: center;

				image {
					width: 140rpx;
					height: 140rpx;
					margin-left: 30rpx;
					border-radius: 50%;
				}

				.center {
					flex: 1;
					display: flex;
					flex-direction: column;
					margin-left: 26rpx;
					font-family: PingFang SC;
					color: #FFFFFF;

					.t1 {
						font-size: 36rpx;
						font-weight: bold;
						line-height: 50rpx;
					}

					.t2 {
						margin-top: 6rpx;
						font-size: 24rpx;
						font-weight: 400;
						line-height: 34rpx;
					}
				}

				.right {
					display: flex;
					flex-direction: column;
					align-items: center;
					margin-right: 84rpx;
					font-family: PingFang SC;
					color: #FFFFFF;
					font-weight: 400;
				
					.t1 {
						font-size: 60rpx;
						line-height: 84rpx;
					}
				
					.t2 {
						font-size: 28rpx;
						line-height: 40rpx;
					}
				}
			}
		}

		.list {
			margin-top: 20rpx;
			padding: 0 30rpx;
			background-color: white;

			.item {
				height: 100rpx;
				display: flex;
				align-items: center;
				border-bottom: 1rpx solid #F5F5F5;

				&:last-child {
					border: none;
				}

				text {
					flex: 1;
					margin-left: 16rpx;
					font-size: 32rpx;
					font-family: PingFang SC;
					font-weight: bold;
					line-height: 44rpx;
					color: #131415;
				}

				.img1 {
					width: 30rpx;
					height: 30rpx;
				}

				.img2 {
					width: 15rpx;
					height: 26rpx;
				}

				.img3 {
					width: 26rpx;
					height: 26rpx;
				}

				.img4 {
					width: 24rpx;
					height: 30rpx;
				}
			}
		}
	}
</style>
